// Decoy falsehood analysis
// Political Communication, accepted SP25

// Data file should be in same directory as this file
use "decoyFalse", clear

// Uses the uncluttered scheme by Gary Kimbrough
// https://gray.kimbrough.info/uncluttered-stata-graphs/
set scheme uncluttered

***
// Variable construction
***

lab def placebo 1 "D favorable" 2 "R favorable"
lab val treat_placebo_w placebo

recode polaf3 (2=1) (1=0) (3=0), gen(repd)
lab def repd 1 "Republican" 0 "Not Republican"
lab val repd repd

// Missing values
recode P1e_w P1b_w P1bn_w (8/9 = .)

// Decoy exposure and belief
recode P1e_w (2=0) (1=1), gen(P1e)
lab var P1e "Heard decoy falsehood before?"
lab def pl 1 "Prior exposure" 0 "No exposure", replace
lab val P1e pl
sum P1e

* Combined belief measure (regardless of exposure)
egen Pb_w=rowmean(P1b_w P1bn_w)
lab var Pb_w "Decoy falsehood belief"
lab val Pb_w P1b_w8
sum Pb_w

* Dichotomous belief measures
recode Pb_w (1=1) (2/6=0), gen(PbStrD)
lab var PbStrD "Confident decoy falsehood is true?"
lab def sbel 1 "Definitely true" 0 "Less confident", replace
lab val PbStrD sbel
sum PbStrD

// In-group and out-group placebo exposure and belief
gen inFavor = 1 if polaf3==treat_placebo_w
replace inFavor = 0 if polaf3==abs(treat_placebo_w-3)
lab def inFavor 1 "Out-group critical" 0 "In-group critical"
lab val inFavor inFavor
* inPe(outPe) indicates exposure to in(out)-group favorable placebo
gen inPe = P1e if polaf3==treat_placebo_w
gen outPe = P1e if polaf3==abs(treat_placebo_w-3)
lab var outPe "Self-reported exposure to in-group critical decoy falsehoods"
lab var inPe "Self-reported exposure to out-group critical decoy falsehoods"
lab val outPe inPe pl
* inPb (outPb) indicates beliefs about in(out)-group favorable placebo
gen inPb = Pb_w if polaf3==treat_placebo_w
gen outPb = Pb_w if polaf3==abs(treat_placebo_w-3)
lab var outPb "Belief in in-group critical decoy falsehoods"
lab var inPb "Belief in out-group critical decoy falsehoods"
* Recode so that higher values denote stronger belief.
recode Pb_w outPb inPb (1=6) (2=5) (3=4) (4=3) (5=2) (6=1)
lab def belief 1 "Definitely false" 2 "Probably false" 3 "Maybe false" ///
	4 "Maybe true" 5 "Probably true" 6 "Definitely true", replace
lab val Pb_w outPb inPb belief 

// Dichotomous in/out belief measures
recode inPb (1/5=0) (6=1), gen(inPbStrD)
recode outPb (1/5=0) (6=1), gen(outPbStrD)
lab var inPbStrD "Strong belief in out-group critical decoy"
lab var outPbStrD "Strong belief in in-group critical decoy"
lab val outPbStrD inPbStrD strbel

//
// Visualizations (and underlying data in table form)
//

* Overall exposure and belief by wave
bysort wave: sum P1e Pb_w

*** FIG 2 (four panels)
* FIG 2A
preserve
egen mInPe = mean(inPe), by(wave)
egen mOutPe = mean(outPe), by(wave)
bysort wave: sum mInPe
bysort wave: sum mOutPe
twoway connected mInPe wave, nodraw ///
	|| connected mOutPe wave, lpattern(dash) ///
	legend(on order(1 "Critical of out-group" 2 "Critical of in-group") ///
	col(1)) title("(a)", size(medium) position(11) span) ///
	subtitle("Exposure", size(medium) position(12) span) ///
	ytitle("Proportion claiming prior exposure", size(medlarge)) ///
	yla(0(.25).35, ang(h)) ytick(0(.05).35) ///
	xtitle("") xline(5,lw(vthin) lc(gs12)) ///
	xla(1 `""Late" "Sep.""' 2 `""Early" "Oct.""' 3 `""Mid" "Oct.""' ///
	4 `""Late" "Oct."' 5 "Election"  ///
	6 `""Mid" "Dec.""' 7 `""Mid" "Jan.""' 8 `""Post-" "Inaug.""') ///
	graphregion(margin(large)) name(fig2a, replace)
restore

* FIG 2B
preserve
egen mInPb = mean(inPbStrD), by(wave)
egen mOutPb = mean(outPbStrD), by(wave)
bysort wave: sum mInPb
bysort wave: sum mOutPb
twoway connected mInPb wave, nodraw ///
	|| connected mOutPb wave, lpattern(dash) ///
	legend(on order(1 "Critical of out-group" 2 "Critical of in-group") ///
	col(1)) title("(b)", size(medium) position(11) span) ///
	subtitle("Belief", size(medium) position(12) span) ///
	ytitle("Proportion claiming strong belief", size(medlarge)) ///
	yla(0(.25).35, ang(h)) ytick(0(.05).35) ///
	xtitle("") xline(5,lw(vthin) lc(gs12)) ///
	xla(1 `""Late" "Sep.""' 2 `""Early" "Oct.""' 3 `""Mid" "Oct.""' ///
	4 `""Late" "Oct."' 5 "Election"  ///
	6 `""Mid" "Dec.""' 7 `""Mid" "Jan.""' 8 `""Post-" "Inaug.""') ///
	graphregion(margin(large)) name(fig2b, replace)
restore

graph combine fig2a fig2b, xsize(6.5) ysize(3.5) name(fig2top, replace)

* FIG 2C
preserve
egen mInPe = mean(inPe), by(wave polaf3)
egen mOutPe = mean(outPe), by(wave polaf3)
twoway connected mInPe wave if polaf3 == 1, nodraw lc(blue) mc(blue) ///
	|| connected mOutPe wave if polaf3 == 1, lpattern(dash) lc(blue) mc(blue) ///
	|| connected mInPe wave if polaf3 == 2, lc(red) mc(red) msym(square) ///
	|| connected mOutPe wave if polaf3 == 2, lpattern(dash) lc(red) mc(red) msym(square) ///
	legend(on order(1 "Out-group critical, Ds" 2 "In-group critical, Ds" ///
	3 "Out-group critical, Rs" 4 "In-group critical, Rs" ) col(1)) ///
	title("(c)", size(medium) position(11) span) ///
	subtitle("Exposure", size(medium) position(12) span) ///
	ytick(0(.05).35) ytitle("Proportion claiming prior exposure", size(medlarge)) ///
	yla(0(.25).35, ang(h)) xtitle("") xline(5,lw(vthin) lc(gs12)) ///
	xla(1 `""Late" "Sep.""' 2 `""Early" "Oct.""' 3 `""Mid" "Oct.""' ///
	4 `""Late" "Oct."' 5 "Election"  ///
	6 `""Mid" "Dec.""' 7 `""Mid" "Jan.""' 8 `""Post-" "Inaug.""') ///
	graphregion(margin(large)) name(fig2c, replace)
restore

* FIG 2D
preserve
egen mInPb = mean(inPbStrD), by(wave polaf3)
egen mOutPb = mean(outPbStrD), by(wave polaf3)
twoway connected mInPb wave if polaf3 == 1, nodraw lc(blue) mc(blue) ///
	|| connected mOutPb wave if polaf3 == 1, lpattern(dash) lc(blue) mc(blue) ///
	|| connected mInPb wave if polaf3 == 2, lc(red) mc(red) msym(square) ///
	|| connected mOutPb wave if polaf3 == 2, lpattern(dash) lc(red) mc(red) msym(square) ///
	legend(on order(1 "Out-group critical, Ds" 2 "In-group critical, Ds" ///
	3 "Out-group critical, Rs" 4 "In-group critical, Rs" ) col(1)) ///
	title("(d)", size(medium) position(11) span) ///
	subtitle("Belief", size(medium) position(12) span) ///
	ytick(0(.05).35) ytitle("Proportion claiming strong belief", size(medlarge)) ///
	yla(0(.25).35, ang(h)) xtitle("") xline(5,lw(vthin) lc(gs12)) ///
	xla(1 `""Late" "Sep.""' 2 `""Early" "Oct.""' 3 `""Mid" "Oct.""' ///
	4 `""Late" "Oct."' 5 "Election"  ///
	6 `""Mid" "Dec.""' 7 `""Mid" "Jan.""' 8 `""Post-" "Inaug.""') ///
	graphregion(margin(large)) name(fig2d, replace)
restore

graph combine fig2c fig2d, xsize(6.5) ysize(3.5) name(fig2bot, replace)

graph combine fig2top fig2bot, col(1) xsize(6.5) ysize(7) ///
	altshrink name(fig2, replace)

//
// Statistical tests
//

// Check for over-time changes in sample
regress age i.wave
logit maled i.wave
ologit educ4 i.wave
logit repd i.wave

// Exposure
* Note: with and without demographic controls

* Mean exposure by decoy slant
proportion P1e, over(inFavor) vce(cluster id)
logit P1e inFavor, or vce(cluster id)
logit P1e maled educ4 age inFavor, or vce(cluster id)

* Repeat by wave (used in visual inspection section paper)
forvalues i = 1/8 {
	display ""
	display "{bf:WAVE `i' EXPOSURE}"
	preserve
	drop if wave != `i'
	proportion P1e, over(inFavor) vce(cluster id)
	logit P1e inFavor, or vce(cluster id)
	restore
}

* Testing potential impact of party on exposure (interaction not reported)
proportion P1e, over(repd) vce(cluster id)
logit P1e inFavor repd, or vce(cluster id)
logit P1e inFavor##repd, or vce(cluster id)

* Repeat by wave, now moderated by party (used in visual inspection section paper)
forvalues i = 1/8 {
	display ""
	display "{bf:WAVE `i' EXPOSURE X PARTY}"
	preserve
	drop if wave != `i'
	logit P1e inFavor##repd, or vce(cluster id)
	restore
}

// Belief
* Mean strong belief by decoy slant
proportion PbStrD, over(inFavor) vce(cluster id)
logit PbStrD inFavor, or vce(cluster id)
logit PbStrD maled educ4 age inFavor, or vce(cluster id)

* Repeat by wave (used in visual inspection section paper)
forvalues i = 1/8 {
	display ""
	display "{bf:WAVE `i' BELIEF}"
	preserve
	drop if wave != `i'
	proportion PbStrD, over(inFavor) vce(cluster id)
	logit PbStrD inFavor, or vce(cluster id)
	restore
}

* Testing potential impact of party on exposure (interaction not reported)
proportion PbStrD, over(repd) vce(cluster id)
logit PbStrD inFavor repd, or vce(cluster id)
logit PbStrD inFavor##repd, or vce(cluster id)

* Repeat by wave, now moderated by party (used in visual inspection section paper)
forvalues i = 1/8 {
	display ""
	display "{bf:WAVE `i' BELIEF X PARTY}"
	preserve
	drop if wave != `i'
	logit PbStrD inFavor##repd, or vce(cluster id)
	restore
}

* Table 2-5
xtlogit outPe ib5.wave, fe level(95) or
xtlogit inPe ib5.wave, fe level(95) or
xtlogit outPbStrD ib5.wave, fe level(95) or
xtlogit inPbStrD ib5.wave, fe level(95) or